﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using FazaDemo.PL.AbstractPresenters;
using FazaDemo.PL.Wpf;
using FazaDemo.PL.EventFactories;

namespace FazaDemo.PL.Wpf.Browser
{
    public class BasePresenter
    {

        private readonly WorkAreaFactory _viewFactory;

        private EventFactory _eventFactory;

        public BasePresenter(WorkAreaFactory viewFactory)
        {
            _viewFactory = viewFactory;
        }

        public Page Initialize(PresenterType presType)
        {
            var provider = new EventFactoryProvider(this);
            _eventFactory = provider.GetEventFactory(presType);
            Page _area = _viewFactory.GetPage(ViewEvent);
            return _area;
        }

        public void ViewEvent(object sender, EventArgs e)
        {
            var concreteEvent = _eventFactory.GetConcreteEvent(sender, HandleFactoryEvents);
            if (concreteEvent != null)
            {
                concreteEvent.EventArgs = e;
                concreteEvent.ExecuteAction();
            }
        }

        private void HandleFactoryEvents(ConcreteEvent e)
        {

        }

    }
}
